import { Router } from "express";
const router = Router();
import { verifyToken } from "../utils/jwt.js";
import {
  getUploadAuth,
  refresghUploadAuth,
  createVideo,
  getPlayAuth,
  getPlayInfo,
  list,
  hots,
  detail,
  remove,
  update,
  like,
  unlike,
  collect,
  uncollect,
  comment,
  comments,
} from "../controllers/videoController.js";
import { uploadValidator } from "../middleware/validator/videoValidator.js";
router
  .post("/upload/auth", verifyToken(), getUploadAuth) // 获取上传凭证
  .post("/upload/auth/refresh", verifyToken(), refresghUploadAuth) // 刷新上传凭证
  .post("/create", verifyToken(), uploadValidator, createVideo) // 上传视频
  .get("/play/auth/:vId", getPlayAuth) // 获取播放凭证
  .get("/play/info/:vodId", getPlayInfo) // 获取播放地址
  .get("/list", list) // 视频列表
  .get("/hots", hots) // 热门视频列表
  .get("/:vId", verifyToken(false), detail)
  .delete("/:vId", verifyToken(), remove)
  .patch("/:vId", verifyToken(), update)
  .post("/:vId/like", verifyToken(), like) // 点赞
  .post("/:vId/unlike", verifyToken(), unlike) // 取消点赞
  .post("/collect", verifyToken(), collect) // 收藏
  .post("/uncollect", verifyToken(), uncollect) // 取消收藏
  .post("/comment", verifyToken(), comment) // 评论
  .get("/comments/:vId", comments); // 获取评论列表

export default router;
